home *** CD-ROM | disk | FTP | other *** search
/ Discovering Windows 98 / WinExpert9.iso / features / VisualBasic / Vb01 / State after this tutorial / frmUnits.frm (.txt) next >
Visual Basic Form  |  1997-11-09  |  4KB  |  122 lines

  1. VERSION 5.00
  2. Begin VB.Form frmUnits 
  3.    Caption         =   "Units Conversion"
  4.    ClientHeight    =   1485
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4065
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   1485
  10.    ScaleWidth      =   4065
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.ComboBox cboConversionTypes 
  13.       Height          =   315
  14.       Left            =   1560
  15.       Style           =   2  'Dropdown List
  16.       TabIndex        =   5
  17.       Top             =   120
  18.       Width           =   2415
  19.    End
  20.    Begin VB.CommandButton cmdConvert 
  21.       Caption         =   "Convert"
  22.       Enabled         =   0   'False
  23.       Height          =   375
  24.       Left            =   2640
  25.       TabIndex        =   4
  26.       Top             =   840
  27.       Width           =   975
  28.    End
  29.    Begin VB.TextBox txtToUnits 
  30.       Enabled         =   0   'False
  31.       Height          =   285
  32.       Left            =   1080
  33.       TabIndex        =   1
  34.       Top             =   1080
  35.       Width           =   855
  36.    End
  37.    Begin VB.TextBox txtFromUnits 
  38.       Height          =   285
  39.       Left            =   1080
  40.       TabIndex        =   0
  41.       Top             =   720
  42.       Width           =   855
  43.    End
  44.    Begin VB.Label Label1 
  45.       Caption         =   "Conversion Type"
  46.       Height          =   255
  47.       Left            =   120
  48.       TabIndex        =   6
  49.       Top             =   120
  50.       Width           =   1335
  51.    End
  52.    Begin VB.Label lblToUnits 
  53.       Caption         =   "<To>"
  54.       Height          =   255
  55.       Left            =   120
  56.       TabIndex        =   3
  57.       Top             =   1080
  58.       Width           =   975
  59.    End
  60.    Begin VB.Label lblFromUnits 
  61.       Caption         =   "<From>"
  62.       Height          =   255
  63.       Left            =   120
  64.       TabIndex        =   2
  65.       Top             =   720
  66.       Width           =   735
  67.    End
  68. Attribute VB_Name = "frmUnits"
  69. Attribute VB_GlobalNameSpace = False
  70. Attribute VB_Creatable = False
  71. Attribute VB_PredeclaredId = True
  72. Attribute VB_Exposed = False
  73. Option Explicit
  74. Private mastrFromUnitNames(0 To 3) As String
  75. Private mastrToUnitNames(0 To 3) As String
  76. Private masngMultiplicationFactors(0 To 3) As Single
  77. Private msngChosenFactor As Single
  78. Private Sub cmdConvert_Click()
  79.     txtCM.Text = txtInches.Text * 2.52
  80. End Sub
  81. Private Sub Form_Load()
  82.     Dim intIndex As Integer
  83.         
  84.     masngMultiplicationFactors(0) = 1.6093
  85.     mastrFromUnitNames(0) = "Miles"
  86.     mastrToUnitNames(0) = "Kilometres"
  87.         
  88.     masngMultiplicationFactors(1) = 0.9144
  89.     mastrFromUnitNames(1) = "Yards"
  90.     mastrToUnitNames(1) = "Metres"
  91.         
  92.     masngMultiplicationFactors(2) = 0.3048
  93.     mastrFromUnitNames(2) = "Feet"
  94.     mastrToUnitNames(2) = "Metres"
  95.         
  96.     masngMultiplicationFactors(3) = 2.52
  97.     mastrFromUnitNames(3) = "Inches"
  98.     mastrToUnitNames(3) = "Centimetres"
  99.         
  100.     For intIndex = 0 To 3
  101.         cboConversionTypes.AddItem mastrFromUnitNames(intIndex) & " to " & mastrToUnitNames(intIndex)
  102.     Next
  103.         
  104.     'Pre-select list item number 0
  105.     cboConversionTypes.ListIndex = 0
  106. End Sub
  107. Private Sub txtFromUnits_Change()
  108.     If txtFromUnits.Text = "" Then
  109.        cmdConvert.Enabled = False
  110.     Else
  111.        cmdConvert.Enabled = True
  112.     End If
  113. End Sub
  114. Private Sub txtFromUnits_KeyPress(KeyAscii As Integer)
  115.     If Not IsNumeric(Chr(KeyAscii)) Then
  116.         If KeyAscii <> 8 Then
  117.             KeyAscii = 0
  118.             Beep
  119.         End If
  120.     End If
  121. End Sub
  122.